<?php
/* ------------------------------------------------------------------------------------------------------------------------------ */

class ccdsObject
{
    private $config;
    private $iClassId;

    private $obj_id;
    private $obj_vers_id;

    private $_has_tables=false;
    private $_has_parameter=false;

    private $ccdSQL;

    private $idField;

    private $debug=array();

    private $ccdsFormFieldHandler;

    private $project_id;


/* ------------------------------------------------------------------------------------------------------------------------------ */

    function __construct( $iObj_id, $class_id=false, $project_id=false )
    {

        $this->ccdSQL=ccdSQL::getInstance();
        $this->tools=ccdsTools::getInstance();
        $this->ccdsFormFieldHandler=ccdsFormFieldHandler::getInstance();

        if ( false == $iObj_id && is_array( $class_id ) )
        {
            $iObj_id=$this->createNew( $class_id );
        }

        if ( !is_numeric( $iObj_id ) )
            return trigger_error( "ccdsObject: obj_id needed. got: " . $iObj_id );

        if ( !$class_id || !$project_id )
        {
            $query="SELECT obj_key_class_id,obj_key_project_id FROM obj_index WHERE obj_id='" . $iObj_id . "' LIMIT 1";
            $res=$this->ccdSQL->query( $query );
            $class=$this->ccdSQL->fetch_assoc( $res );
            $this->iClassId=$class['obj_key_class_id'];
            $this->project_id=$class['obj_key_project_id'];
        }
        else
        {
            $this->project_id=$project_id;
            $this->iClassId=$class_id;
        }
        $ObjectConfig=ccdsObjectConfig::getInstance();

        $this->ObjectConfig=$ObjectConfig;
        $this->config=$ObjectConfig->getClass( $this->iClassId );

        unset( $xml );

        if ( is_array( $this->config ) )
        {
            if ( is_array( $this->config['data'] ) )
            {
                $this->_has_tables=true;

                if ( is_array( $this->config['data']['columns'] ) )
                {
                    foreach ( $this->config['data']['columns'] as $fieldname => $values )
                    {
                        if ( $values['label'] == "id" )
                        {
                            $this->idField=$fieldname;
                        }
                    }
                }
            }

            if ( isset( $this->config['parameter'] ) )
            {
                if ( is_array( $this->config['parameter'] ) )
                    $this->_has_parameter=true;
            }
        }

        $this->obj_id=$iObj_id;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */
    function getObjId( )
    {
        return $this->obj_id;
    }

    function createNew( $params )
    {
        if ( !isset( $params['obj_parent_obj_id'] ) && empty( $params['obj_parent_obj_id'] )
            && is_numeric( $params['obj_parent_obj_id'] ) )
        {
            trigger_error( "cannot create new object: missing obj_parent_obj_id " );
            return;
        }

        if ( ( !isset( $params['obj_name'] )
            && empty( $params['obj_name'] )) AND ( !isset( $params['obj_name_name'] )
            && empty( $params['obj_name_name'] )) )
        {
            trigger_error( "cannot create new object: missing obj_name" );
            return;
        }

        if ( !isset( $params['class_id'] ) && empty( $params['class_id'] ) && is_numeric( $params['class_id'] ) )
        {
            trigger_error( "cannot create new object: missing obj_parent_obj_id " );
            return;
        }

        if ( !isset( $params['lang_id'] ) && empty( $params['lang_id'] ) && is_numeric( $params['lang_id'] ) )
        {
            trigger_error( "cannot create new object: missing lang_id " );
            return;
        }

        if ( "" != $params['obj_name_name'] )
            $params['obj_name']=$params['obj_name_name'];

        $params['obj_is_navi']=isset( $params['obj_is_navi'] ) ? $params['obj_is_navi'] : 0;
        $params['obj_no_structure']=isset( $params['obj_no_structure'] ) ? $params['obj_no_structure'] : 0;

        if ( '' == $params['project_id'] )
        {
            $query=
                "SELECT obj_key_project_id FROM obj_index WHERE obj_id='" . addslashes( $params['obj_parent_obj_id'] )
                . "' LIMIT 1";
            $res=$this->ccdSQL->query( $query );
            $project=$this->ccdSQL->fetch_assoc( $res );
            $params['project_id']=$project['obj_key_project_id'];
        }

        $query=
            "SELECT obj_position FROM obj_index WHERE obj_parent_obj_id='" . $params['obj_parent_obj_id']
            . "' order by obj_position desc LIMIT 1";
        $res=$this->ccdSQL->query( $query );
        $pos=$this->ccdSQL->fetch_assoc( $res );

        $query=
            "SELECT tpl_id FROM templates LEFT JOIN mn_template_class ON (tpl_class_key_tpl_id = tpl_id) WHERE tpl_class_key_class_id='"
            . $params['class_id'] . "' ORDER BY tpl_class_default desc LIMIT 1";
        $res=$this->ccdSQL->query( $query );
        $tpl=$this->ccdSQL->fetch_assoc( $res );

        $query="INSERT INTO obj_index
             (
             obj_parent_obj_id,
             obj_key_tpl_id,
             obj_created,
             obj_created_key_user_id,
             obj_key_class_id,
             obj_position,
             obj_key_project_id,
             obj_is_navi,
             obj_no_structure,
             obj_last_edit_key_user_id
             )
             VALUES (
             '" . $params['obj_parent_obj_id'] . "',
             '" . $tpl['tpl_id'] . "',
             '" . time() . "',
             '" . $params['user_id'] . "',
             '" . $params['class_id'] . "',
             '" . ( $pos['obj_position'] + 1 ) . "',
             '" . $params['project_id'] . "',
             '" . $params['obj_is_navi'] . "',
             '" . $params['obj_no_structure'] . "',
             '" . $params['user_id'] . "'
             )
             ";
        $res=$this->ccdSQL->query( $query );

        $new_obj_id=$this->ccdSQL->insert_id();

        if ( !$new_obj_id )
        {
            trigger_error( "cannot create new object, bad input" );
            return;
        }

        $query="INSERT INTO obj_names
             (
             obj_name_key_obj_id,
             obj_name_key_lang_id,
             obj_name_name,
             obj_name_serialized
             )
             VALUES (
             '" . $new_obj_id . "',
             '" . $params['lang_id'] . "',
             '" . addslashes( $params['obj_name'] ) . "',
             '" . $this->tools->serialize_name( $params['obj_name'], $params['obj_parent_obj_id'], $params['lang_id'], $new_obj_id ) . "'
             )
             ";
        $this->ccdSQL->query( $query );

        return $new_obj_id;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    function debug( $msg )
    {
        $this->debug[]=$msg;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    function getTable( )
    {
        if ( $this->hasContent() )
            return $this->config['data']['name'];
        return false;
    }

    function getdebug( )
    {

        $out=implode( "\n", $this->debug );

        $this->debug=array();

        return $out;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    function __getIDfield( )
    {
        return $this->idField;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */
    function getObject( $language_id, $display_contents=true )
    {

        $obj_id=$this->obj_id;
        $elements=array();
        $query="
								SELECT 
									* 
								FROM 
									obj_index 

								";

        if ( $display_contents && $this->_has_tables )
        {

            $query.="
								LEFT OUTER JOIN obj_versions ON (
									obj_vers_key_obj_id = IF( obj_link_obj_id > 0, obj_link_obj_id, obj_id ) 
									AND
									obj_vers_key_lang_id = " . $language_id . "
									AND 
									obj_vers_visible=1
								)
								LEFT OUTER JOIN " . $this->config['data']['name'] . " ON (
									obj_vers_id = " . $this->idField . "
								)
			";
        }
        $query.="
								LEFT JOIN
									classes ON 
									(obj_key_class_id=class_id)
								LEFT JOIN templates ON
									(obj_key_tpl_id=tpl_id)
									
								WHERE 1
								AND obj_id='" . $obj_id . "'
							";
        $res=$this->ccdSQL->query( $query );
        print $this->ccdSQL->error();

        if ( $row=$this->ccdSQL->fetch_assoc( $res ) )
        {
            if ( $row['obj_link_obj_id'] > 0 )
            {
                $query="SELECT * FROM obj_index 
										LEFT JOIN
											classes ON 
											(obj_key_class_id=class_id)
										LEFT JOIN templates ON
											(obj_key_tpl_id=tpl_id)				
					
										WHERE obj_id='"
                    . $row['obj_link_obj_id'] . "'";
                $res2=$this->ccdSQL->query( $query );
                $obj=$this->ccdSQL->fetch_assoc( $res2 );
                $obj['obj_link_obj_id']=$row['obj_link_obj_id'];
                $obj['obj_parent_obj_id']=$row['obj_parent_obj_id'];

                $obj['obj_expire']=$row['obj_expire'];
                $obj['obj_expire_start']=$row['obj_expire_start'];
                $obj['obj_expire_end']=$row['obj_expire_end'];
                $obj['obj_is_navi']=$row['obj_is_navi'];

                if ( $row['obj_key_tpl_id'] > 0 )
                {
                    $obj['obj_key_tpl_id']=$row['obj_key_tpl_id'];
                    $obj['tpl_id']=$row['tpl_id'];
                    $obj['tpl_name']=$row['tpl_name'];
                    $obj['tpl_file']=$row['tpl_file'];
                    $obj['tpl_dir']=$row['tpl_dir'];
                }
                $load_obj=$obj['obj_id'];
                $obj['obj_id']=$row['obj_id'];
                $row=$obj;
            }
            else
            {
                $load_obj=$row['obj_id'];
            }
            $obj_name=$this->getName( $language_id );
            $row=array_merge( $row, $obj_name );

            if ( $display_contents && $this->_has_tables )
            {
                $row['CONTENT']=array();

                foreach ( $this->config['data']['columns'] as $fieldname => $fieldconfig )
                {
                    $row['CONTENT'][$fieldname]=$row[$fieldname];
                    unset( $row[$fieldname] );
                }
                $row['CONTENT']=$this->_parseValues( $this->config['data']['columns'], $row['CONTENT'] );
            }

            if ( ( $this->hasParameter() == true ) AND ( isset( $row['obj_attributes'] )) )
            {
                $row['obj_attributes']=$this->__unSerializeParameter( $row['obj_attributes'], $language_id );
            }
        }
        else
        {
            $row="";
        }

        $row['CODE']=$this->tools->load_plugin_frontend_function( $row['obj_id'], $row );

        $this->ccdSQL->free_result( $res );
        return $row;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    function getName( $lang_id, $prefix=false )
    {

        $obj_id=$this->obj_id;

        $query="SELECT obj_link_obj_id FROM obj_index WHERE obj_id='" . $obj_id . "'";
        $res=$this->ccdSQL->query( $query );
        $objrow=$this->ccdSQL->fetch_assoc( $res );

        if ( $objrow['obj_link_obj_id'] > 0 )
            $obj_id=$objrow['obj_link_obj_id'];

        $this->ccdSQL->free_result( $res );

        $query=
            "SELECT obj_name_name,obj_name_serialized FROM obj_names WHERE obj_name_key_obj_id='" . $obj_id
            . "' AND obj_name_key_lang_id='" . $lang_id . "'";
        $res=$this->ccdSQL->query( $query );

        if ( $this->ccdSQL->num_rows( $res ) == 0 )
        {
            $query=
                "SELECT obj_name_name,obj_name_serialized FROM obj_names WHERE obj_name_key_obj_id='" . $obj_id
                . "' AND obj_name_key_lang_id='" . MMCMS_DEFAULT_LANG . "'";
            $res=$this->ccdSQL->query( $query );
            $row=$this->ccdSQL->fetch_assoc( $res );
            $row['obj_name_name']="[" . MMCMS_DEFAULT_LANG_CODE . "] " . $row['obj_name_name'];
        }
        else
        {
            $row=$this->ccdSQL->fetch_assoc( $res );
            $this->ccdSQL->free_result( $res );
        }

        if ( ( $objrow['obj_link_obj_id'] > 0 ) AND ($prefix) )
        {
            $row['obj_name_name']="@" . $row['obj_name_name'];
        }
        return $row;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    function getObjVersId( )
    {
        return $this->obj_vers_id;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    function __getVersionRow( $obj_vers_id )
    {

        $sQuery=
            "SELECT * FROM " . $this->config['data']['name'] . " WHERE " . $this->idField . "='" . $obj_vers_id . "'";
        $sRes=$this->ccdSQL->query( $sQuery );

        $aRow=$this->ccdSQL->fetch_assoc( $sRes );

        return $aRow;
    }
/* ------------------------------------------------------------------------------------------------------------------------------ */

    private function _parseValues( $columns, &$aRow )
    {
        foreach ( $columns as $fieldname => $fieldConfig )
        {

            $obj_vers_id=isset( $aRow[$this->__getIDfield()] ) ? $aRow[$this->__getIDfield()] : false;

            if ( "fieldset" == $fieldname )
            {
                $aRow=array_merge( $aRow, $this->_parseValues( $fieldConfig, $aRow ) );
            }
            elseif ( "@attributes" == $fieldname ) {}
            else
            {

                $aRow[$fieldname]=$this->ccdsFormFieldHandler->getFieldValue( $fieldConfig, $fieldname,
                    $aRow[$fieldname], $obj_vers_id );
            }
        }
        return $aRow;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    public function getDetails( $language_id, $obj_vers_id=false )
    {
        $obj=array();

        if ( !$obj_vers_id )
        {
            $query=
                "SELECT obj_vers_id FROM obj_versions WHERE obj_vers_key_obj_id='" . $this->obj_id
                . "' AND obj_vers_key_lang_id='"
                . $language_id . "' AND obj_vers_visible=1  ORDER BY obj_vers_created DESC LIMIT 1";
            $res=$this->ccdSQL->query( $query );
            $obj_vers=$this->ccdSQL->fetch_assoc( $res );
            $obj_vers_id=$obj_vers['obj_vers_id'];
        }

        $this->ccdSQL->free_result( $res );

        $aRow=$this->__getVersionRow( $obj_vers_id );
        $obj=$this->_parseValues( $this->config['data']['columns'], $aRow );

        $obj['obj_id']=$this->obj_id;
        return $obj;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    private function _parseForm( $columns, $aRow, $language_id )
    {

        $ret=array();

        if ( !is_array( $columns ) )
            return;

        foreach ( $columns as $fieldname => $fieldConfig )
        {
            if ( "fieldset" == $fieldname )
            {
                $ret[]=array
                    (
                    "formtype" => "fieldset",
                    "label" => $values['@attributes']['label'],
                    "fields" => $this->_parseForm( $fieldConfig, $aRow, $language_id )
                    );
            }
            elseif ( "@attributes" == $fieldname ) {}
            else
            {
                $obj_vers_id=isset( $aRow[$this->__getIDfield()] ) ? $aRow[$this->__getIDfield()] : false;
                $value=isset( $aRow[$fieldname] ) ? $aRow[$fieldname] : NULL;

                if ( $array=$this->ccdsFormFieldHandler->getFieldEditArray( $fieldConfig, $fieldname, $value,
                    $this->project_id, $language_id, $obj_vers_id ) )
                {
                    $ret[$fieldname]=$array;
                }
            }
        }

        return $ret;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    public function getEditArray( $obj_vers_id, $language_id )
    {
        if ( $obj_vers_id != false )
        {
            $aRow=$this->__getVersionRow( $obj_vers_id );
        }
        else
        {
            $aRow=array();
        }

        if ( is_array( $this->config['data'] ) )
            return $this->_parseForm( $this->config['data']['columns'], $aRow, $language_id );
        return false;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */
    private function __getPreparedData( &$fieldConfig, &$fieldname, &$values )
    {

        $ret=$this->ccdsFormFieldHandler->getFieldPreparedData( $fieldConfig, $fieldname, $values );

        return $ret;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    function save( $FormValues, $lang_id=false )
    {
        if ( !$lang_id )
        {
            trigger_error( "language id needed" );
        //$lang_id = $_SESSION['CMS']['user_lang_id'];
        }
        $create_new_entry=true;

        if ( isset( $FormValues['obj_vers_id'] ) )
        {
            if ( is_numeric( $FormValues['obj_vers_id'] ) )
            {
                $query="SELECT * FROM obj_versions WHERE obj_vers_id = '" . $FormValues['obj_vers_id'] . "'";
                $res=$this->ccdSQL->query( $query );
                $row=$this->ccdSQL->fetch_assoc( $res );

                $this->debug( $row['obj_vers_visible'] );

                if ( 0 == $row['obj_vers_visible'] )
                    $create_new_entry=false;
            }
        }

        if ( $create_new_entry == false )
        {

            $query="UPDATE " . $this->config['data']['name'] . " SET	";
            $seperator="";

            foreach ( $this->config['data']['columns'] as $fieldname => $fieldconfig )
            {
                if ( $fieldconfig['label'] != "id" && $fieldname != "fieldset" && $fieldname != "comment" )
                {
                    $query.=$seperator . $fieldname . "='"
                        . $this->__getPreparedData( $fieldconfig, $fieldname, $FormValues ) . "'";
                    $seperator=", ";
                }
            }
            $query.="WHERE " . $this->__getIDfield( $this->config['data'] ) . "='" . $FormValues['obj_vers_id'] . "'";
            $res=$this->ccdSQL->query( $query );
            return $FormValues['obj_vers_id'];
        }
        else
        {
            if ( isset( $FormValues['obj_vers_id'] ) )
            {
                $visible=0;
            }
            else
            {
                $visible=1;
            }
            $query="INSERT INTO obj_versions 
								(
									obj_vers_key_obj_id,
									obj_vers_created,
									obj_vers_creator,
									obj_vers_key_lang_id,
									obj_vers_visible
								)
								VALUES (
									'" . $this->obj_id . "',
									'" . time() . "',
									'" . $_SESSION['CMS']['user_id'] . "',
									'" . $lang_id . "',
									'" . $visible . "'
								)
							 ";
            $res=$this->ccdSQL->query( $query );
            $new_vers_id=$this->ccdSQL->insert_id();

            $FormValues['obj_vers_id']=$new_vers_id;

            $query="INSERT INTO " . $this->config['data']['name'] . " ";
            $seperator="";
            $query_fields="";
            $query_values="";

            foreach ( $this->config['data']['columns'] as $fieldname => $fieldconfig )
            {
                if ( $fieldname != "fieldset" && $fieldname != "comment" )
                {
                    $query_fields.=$seperator . $fieldname;

                    if ( $fieldconfig['label'] != "id" )
                    {
                        $query_values.=$seperator . "'"
                            . $this->__getPreparedData( $fieldconfig, $fieldname, $FormValues ) . "'";
                    }
                    else
                    {
                        $query_values.=$seperator . "'" . $new_vers_id . "'";
                    }
                    $seperator=", ";
                }
            }
            $res=$this->ccdSQL->query( $query . "(" . $query_fields . ") VALUES(" . $query_values . ")" );
            $saved_id=$this->ccdSQL->insert_id();
            $this->debug( $query . "(" . $query_fields . ") VALUES(" . $query_values . ")" );

            return $new_vers_id;
        }
    }
/* ------------------------------------------------------------------------------------------------------------------------------ */
    private function __getPreparedParameterData( $fieldconfig, $fieldname, $values, $language )
    {

        $ret=$this->ccdsFormFieldHandler->getFieldPreparedParameterData( $fieldconfig, $fieldname, $values );
        return $ret;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    function saveParameter( $FormValues, $language )
    {

        $parameter=array();

        foreach ( $this->config['parameter'] as $fieldname => $fieldconfig )
        {
            if ( $values['label'] != "id" )
            {
                $parameter[$fieldname]=$this->ccdsFormFieldHandler->getFieldPreparedParameterData( $fieldconfig,
                    $fieldname, $FormValues, $this->getObjId() );
            }
        }

        $query="SELECT * FROM obj_index WHERE obj_id='" . $this->obj_id . "'";
        $res=mysql_query( $query );
        $row=mysql_fetch_assoc( $res );

        $params=unserialize( $row['obj_attributes'] );

        if ( !is_array( $params ) )
            $params=array();
        $params[$language]=$parameter;

        $serialized=serialize( $params );

        mysql_query( "UPDATE obj_index SET obj_attributes = '" . $this->ccdSQL->real_escape_string( $serialized )
            . "' WHERE obj_id='" . $this->obj_id . "'" );

        return $params;
    }
/* ------------------------------------------------------------------------------------------------------------------------------ */

    private function __unSerializeParameter( $parameter, $language_id )
    {
        if ( !is_array( $this->config['parameter'] ) )
            return array();

        if ( !$params=unserialize( $parameter ) ) {
        //throw new Exception("DeSerialize Failed");
        }

        if ( !is_array( $params[$language_id] ) )
            $params[$language_id]=array();

        $parameter=array();

        if ( !is_array( $params[$language_id] ) )
            return array();

        foreach ( $this->config['parameter'] as $fieldname => $fieldconfig )
        {
            $parameter[$fieldname]=$this->ccdsFormFieldHandler->getFieldParameterValue( $fieldconfig, $fieldname,
                $params[$language_id][$fieldname], $this->getObjId() );
        }

        return $parameter;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    function __unSerializeParameterRaw( $parameter, $language_id )
    {
        if ( !$params=unserialize( $parameter ) ) {
        //throw new Exception("DeSerialize Failed");
        }

        return $params[$language_id];
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    private function __parseParameter( $fieldConfig, $fieldname, $values, $project_id, $language_id )
    {

        $ret=
            $this->ccdsFormFieldHandler->getFieldParameterArray( $fieldConfig, $fieldname, $values, $project_id,
                $language_id );

        return $ret;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    public function getParameterArray( $language_id )
    {
        if ( !$this->hasParameter() )
            return false;
        $sQuery="SELECT obj_attributes,obj_key_project_id FROM obj_index WHERE obj_id='" . $this->obj_id . "' LIMIT 1";
        $sRes=$this->ccdSQL->query( $sQuery );
        $aRow=$this->ccdSQL->fetch_assoc( $sRes );

        $aParameter=$this->__unSerializeParameterRaw( $aRow['obj_attributes'], $language_id );

        foreach ( $this->config['parameter'] as $fieldname => $fieldconfig )
        {
            $aFormFields[]=$this->__parseParameter( $fieldconfig, $fieldname, $aParameter[$fieldname],
                $aRow['obj_key_project_id'], $language_id );
        }
        return $aFormFields;
    }


/* ------------------------------------------------------------------------------------------------------------------------------ */

    public function hasContent( )
    {
        return $this->_has_tables;
    }

/* ------------------------------------------------------------------------------------------------------------------------------ */

    public function hasParameter( )
    {
        return $this->_has_parameter;
    }

/* function setVisiblity(); ------------------------------------------------------------------------------------------------------ 
   hinzugefügt von steffen:
   setzen der sichtbarkeit des objekts

   @lang_id: die sprach-id des objekts
   @visible: true doer false
   @recursive: wenn true, wird die sichtbarkeit auch für darunterleigende objekte gesetzt
   @obj_id: wird für die rekursion benutzt, um die sichtbarkeit eines anderen objekts zu setzen
*/

    public function setVisibility( $lang_id, $visible, $recursive=false, $obj_id=null )
    {
        if ( $obj_id !== null )
        {
            $q_obj_id=$obj_id;
        }
        else
        {
            $q_obj_id=$this->obj_id;
        }

        $this->ccdSQL->query( "DELETE FROM obj_index_public WHERE objp_key_obj_id='" . $q_obj_id
            . "' AND objp_key_lang_id='" . $lang_id . "'" );

        if ( $visible )
            $this->ccdSQL->query( "INSERT INTO obj_index_public VALUES('" . $q_obj_id . "','" . $lang_id . "')" );

        if ( $recursive != false )
        {
            $query="SELECT * FROM obj_index WHERE obj_parent_obj_id='" . $q_obj_id . "'";
            $res=$this->ccdSQL->query( $query );

            while ( $row=$this->ccdSQL->fetch_array( $res ) )
            {
                $this->setVisibility( $lang_id, $visible, true, $row['obj_id'] );
            }
        }
    }

/* function delete() ----------------------------------------------------------------------------------------------------------------
    hinzugefügt von steffen:
    komplettes löschen des objekts. es werden alle versionen, namen, etc aus der DB gelöscht. inklusive inhalte und parametern.	
*/

    public function delete( )
    {
        $tableName=$this->getTable();

        if ( $tableName != false ) {}
    }
}
?>